import { createSlice } from "@reduxjs/toolkit";

const counterSlice = createSlice({
  name: "count", //模块名
  initialState: {
    //默认数据
    num: 100,
  },
  reducers: {
    //触发数据变化的方法
    increment(state) {
      state.num++;
    },
    decrement(state) {
      state.num--;
    },
  },
});

export const { increment, decrement } = counterSlice.actions;
export default counterSlice.reducer;
